<!--
 * new page
 * @author: eminem89
 * @since: 2023-12-24
 * Person.vue
-->
<template>
    <div class="person">
        <h2>汽车信息:一辆{{ car.brand }}车，价值{{ car.price }}万</h2>
        <button @click="changePrice">修改汽车的价格</button>
        <br />
        <h2>当前求和：{{ sum }}</h2>
        <button @click="changeSum">点我sum+1</button>
        <button @click="changeCar">修改汽车</button>
    </div>
</template>

<script setup lang="ts" name="Person">
import { ref, reactive } from 'vue';
//数据
let car = reactive({
    brand: '奔驰',
    price: 100,
});

let sum = ref(0);

let games = ref([
    { id: 'asewrewr01', name: '王者荣耀' },
    { id: 'asewrewr02', name: '英雄联盟' },
    { id: 'asewrewr03', name: '三国志' },
]);

//方法
function changePrice() {
    car.value.price += 10;
}

function changeSum() {
    sum.value += 1;
}

function changeCar() {
    Object.assign(car, { brand: '路虎', price: 50 });
}
</script>

<style scoped>
.person {
    background-color: skyblue;
    box-shadow: 0 0 10px;
    border-radius: 10px;
    padding: 20px;
}

button {
    margin: 0 5px;
}
</style>
